package com.koron.operation.classes.shift.service.impl;


import com.koron.operation.classes.shift.bean.po.ClassesAdjustRecord;
import com.koron.operation.classes.shift.mapper.ClassesAdjustRecordMapper;
import com.koron.operation.classes.shift.service.ClassesAdjustRecordService;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 人员调整记录(ClassesAdjustRecord)表服务实现类
 *
 * @author jzp
 * @since 2021-10-27 14:33:51
 */
@Service
public class ClassesAdjustRecordServiceImpl implements ClassesAdjustRecordService {

    /**
     * 通过ID查询单条数据
     */
    @Override
    @TaskAnnotation("getById")
    public ClassesAdjustRecord getById(SessionFactory factory, String id) {
        ClassesAdjustRecordMapper mapper = factory.getMapper(ClassesAdjustRecordMapper.class);
        return mapper.selectById(id);
    }

    /**
     * 查询所有数据
     */
    @Override
    @TaskAnnotation("list")
    public List<ClassesAdjustRecord> list(SessionFactory factory, ClassesAdjustRecord classesAdjustRecord) {
        ClassesAdjustRecordMapper mapper = factory.getMapper(ClassesAdjustRecordMapper.class);
        return mapper.selectList(classesAdjustRecord);
    }

    /**
     * 新增数据
     */
    @Override
    @TaskAnnotation("save")
    public boolean save(SessionFactory factory, ClassesAdjustRecord classesAdjustRecord) {
        ClassesAdjustRecordMapper mapper = factory.getMapper(ClassesAdjustRecordMapper.class);
        return mapper.insertOrUpdate(classesAdjustRecord) > 0;
    }

    /**
     * 修改数据
     */
    @Override
    @TaskAnnotation("update")
    public boolean update(SessionFactory factory, ClassesAdjustRecord classesAdjustRecord) {
        ClassesAdjustRecordMapper mapper = factory.getMapper(ClassesAdjustRecordMapper.class);
        return mapper.update(classesAdjustRecord) > 0;
    }

    /**
     * 通过主键删除数据
     */
    @Override
    @TaskAnnotation("deleteById")
    public boolean deleteById(SessionFactory factory, String id) {
        ClassesAdjustRecordMapper mapper = factory.getMapper(ClassesAdjustRecordMapper.class);
        return mapper.hidden(id) > 0;
    }
}
